﻿Imports System.Data.SqlClient

Public Class clsNotas
    Private cnConn As New SqlConnection
    Private Command As SqlCommand
    Public Sub CONECTAR_BD()
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Command = New SqlCommand("INSERT INTO NOTAS_OPERACIONES VALUES(@DESCRIPCION,@CLAVE,@FECHA,@NOMBRE, @IDMODULO)", cnConn)
        Command.CommandTimeout = 0

        Command.Parameters.Add(New SqlParameter("@DESCRIPCION", SqlDbType.VarChar, 500))
        Command.Parameters.Add(New SqlParameter("@CLAVE", SqlDbType.VarChar, 500))
        Command.Parameters.Add(New SqlParameter("@FECHA", SqlDbType.DateTime))
        Command.Parameters.Add(New SqlParameter("@NOMBRE", SqlDbType.VarChar, 200))
        Command.Parameters.Add(New SqlParameter("@IDMODULO", SqlDbType.Int))

        Try
            cnConn.Open()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End Try

    End Sub
    Public Sub Insertar(ByVal CLAVE As String, ByVal DESCRIPCION As String, ByVal FECHA As Date, ByVal MODULO As Integer)
        Command.Parameters("@DESCRIPCION").Value = DESCRIPCION
        Command.Parameters("@CLAVE").Value = CLAVE
        Command.Parameters("@FECHA").Value = FECHA
        Command.Parameters("@NOMBRE").Value = UsuarioActivo
        Command.Parameters("@IDMODULO").Value = MODULO

        Try
            Command.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")

        End Try
    End Sub
    Public Sub Cerrar_BD()
        If cnConn.State = ConnectionState.Open Then
            cnConn.Close()
        End If
    End Sub
End Class
